<%--
  Created by IntelliJ IDEA.
  User: sofwin
  Date: 2021/9/24
  Time: 9:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%String path = request.getContextPath()+"/";%>
<html>
<head>
    <base href="<%=path%>">
    <title>Title</title>
    <title>权限管理登录</title>
    <link href="hplus-master/css/bootstrap.min.css" rel="stylesheet">
    <link href="hplus-master/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="hplus-master/css/animate.css" rel="stylesheet">
    <link href="hplus-master/css/style.css" rel="stylesheet">
    <link href="hplus-master/css/login.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>

</head>

<body class="signin">
<div class="signinpanel">
    <div class="row">
        <div class="col-sm-7">
            <div class="signin-info">
                <div class="logopanel m-b">
                    <h1>[ Sofwin ]</h1>
                </div>
                <div class="m-b"></div>
                <h4>欢迎使用 <strong> 权限管理系统</strong></h4>
                <ul class="m-b">
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Spring mvc</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> mybatis</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> bootstrap</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> shiro</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Rbac</li>
                </ul>
                <strong>还没有账号？ <a href="#">立即注册&raquo;</a></strong>
            </div>
        </div>
        <div class="col-sm-5">
            <form method="post" id="loginForm" >
                <h4 class="no-margins">登录：</h4>
                <p class="m-t-md">登录权限管理系统</p>
                <input type="text" class="form-control uname" placeholder="用户名" name="loginName"/>
                <input type="password" class="form-control pword" placeholder="密码" name="loginPwd"/>
                <div class="input-group m-t m-b">
                    <input type="text" style="color:black;" name="code" class="form-control no-margins" placeholder="验证码">
                    <span class="input-group-addon no-padding"><img src="verification" height="32" onclick="change(this);" title="点击换一换"></span>
                </div>
                <a href="">忘记密码了？</a>
                <button class="btn btn-success btn-block" type="button" id="login">登录</button>
            </form>
        </div>
    </div>
    <div class="signup-footer">
        <div class="pull-left">
            &copy; 2015 All Rights Reserved. H+
        </div>
    </div>
</div>
</body>
<script src="hplus-master/js/jquery.min.js"></script>
<script src="hplus-master/js/plugins/layer/layer.min.js"></script>
<script>
    function change(obj){
        obj.src="verification?t="+new Date();
    }
    $(function () {
        // 登录事件
        $("#login").click(function(){
            var param = $("#loginForm").serialize();
            // 参数是以json对象为格式
            $.ajax({
                url:'login',
                type:'post',
                dataType:'json',
                data:param,
                success:function (ret) {
                    if(ret.code==200){
                        layer.msg('登录成功', {
                            offset: '0px',
                            anim: 6
                        });
                        console.info("跳转到其他页面的")
                        document.location.href="index";
                        return;
                    }
                    if(ret.code==600){
                        layer.msg('用户名不存在', {
                            offset: '0px',
                            anim: 6
                        });
                        $(".uname").val('');
                        $(".uname").focus();
                        return;
                    }
                    if(ret.code==601){
                        layer.msg('用户名或密码错误', {
                            offset: '0px',
                            anim: 6
                        });
                        $(".uname").val('');
                        $(".pword").val('');
                        return;
                    }
                    if(ret.code==602){
                        layer.msg(ret.msg, {
                            offset: '0px',
                            anim: 6
                        });
                        return;
                    }
                }
            });
        })
    })
</script>

</html>